﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HRProject.Code.DTO;
using HRProject.Code.DAO;
using System.Collections.Generic;

namespace HRProject
{
    public partial class Front : System.Web.UI.MasterPage
    {
        private BLJobTitle company;

        public BLJobTitle Company
        {
            get { return company; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            {
                JobTitleDAO jobTitleDao = new JobTitleDAO();
                BLJobTitle jobTitleFilter = new BLJobTitle();
                jobTitleFilter.Id = Guid.Empty;
                jobTitleFilter.Name = string.Empty;
                List<BLJobTitle> jobTitles = jobTitleDao.Search(jobTitleFilter);
                company = jobTitleDao.BuildTree(jobTitles,Guid.Empty);
            }
        }

        public void PrintJobTitle(BLJobTitle jobTitle)
        {
            Response.Write("<li id=\"");
            Response.Write(jobTitle.Id);
            Response.Write("\"><a href=\"javascript:void(0);\">");
            Response.Write(jobTitle.Name);
            Response.Write("</a>");
            if (jobTitle.Children.Count > 0)
            {
                Response.Write("<ul>");
            }
            foreach (BLJobTitle child in jobTitle.Children)
            {
                PrintJobTitle(child);
            }
            if (jobTitle.Children.Count > 0)
            {
                Response.Write("</ul>");
            }
            Response.Write("</li>");
        }
    }
}
